﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using HNQXYJ.Model;
using HNQXYJ.BLL;

namespace HNQXYJ.HN_User
{
    public partial class UserAdd : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void add_Click(object sender, ImageClickEventArgs e)
        {
            Users user = new Users();
            user.UserName = this.txtUserName.Text.Trim();
            user.TrueName = this.txtTrueName.Text.Trim();
            user.Password = UsersBLL.GetMD5(this.txtPwd.Text.Trim());
            //省级权限
            if (this.HidCity.Value=="")
            {
                user.RankName = "河南省";
                user.RankLevel = "1";
            }
            //市级权限
            if (this.HidCity.Value != "" && this.HidCounty.Value == "")
            {
                user.RankName = this.cityName.Value;
                user.RankLevel = this.HidCity.Value;
            }
            //县级权限
            if (this.HidCity.Value != "" && this.HidCounty.Value != "")
            {
                user.RankName = this.cityName.Value + this.countyName.Value;
                user.RankLevel = this.HidCounty.Value;
 
            }
            user.TouchMethod = this.txtTouchMehtod.Text;
            user.AddDate = DateTime.Now;
            user.ErrTimes = 0;
            user.Notes = this.txtNotes.Text;

            int res = new UsersBLL().AddNew(user);
            if (res > 0)
            {
                Response.Redirect("UserMgr.aspx");
            }         
        }

        protected void reset_Click(object sender, ImageClickEventArgs e)
        {
            Response.Redirect("UserMgr.aspx");
        }
       
    }
}